<template>
<h1>表单组件</h1>
  <el-form style="width:500px;margin:0 auto;" label-width="80">
    <el-form-item label="用户名">
    <el-input v-model="user.username" placeholder="请输入用户名"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="user.password" show-password placeholder="请输入密码"></el-input>
    </el-form-item>
    <el-form-item label="性别">
      <el-radio-group v-model="user.gender">
        <el-radio-button label="男" value="男"></el-radio-button>
        <el-radio-button label="女" value="女"></el-radio-button>
      </el-radio-group>
    </el-form-item>
    <el-form-item label="所在地">
      <el-select placeholder="请选择城市" v-model="user.city">
        <el-option value="bj" label="北京"></el-option>
        <el-option value="sh" label="上海"></el-option>
        <el-option value="wh" label="武汉"></el-option>
        <el-option value="hz" label="杭州"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="管理员">
      <el-switch v-model="user.is_admin"></el-switch>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">点我提交</el-button>
      <el-button>Cancel</el-button>
    </el-form-item>

  </el-form>
</template>
<script setup>
  import {ref} from "vue";

  const user = ref({
    username:'',
    password:'',
    gender:'',
    city:'',
    is_admin:true
  })
  const onSubmit = ()=>{
    console.log(user.value);
  }
</script>


<style scoped>

</style>